import request from '@/utils/request'

const api_name = '/admin/acl/user'

export default {

    getPageList(page, limit, category, searchObj) {
        return request({
            url: `${api_name}/${page}/${limit}/${category}`,
            method: 'get',
            params: searchObj // url查询字符串或表单键值对
        })
    },
    getById(id) {
        return request({
            url: `${api_name}/get/${id}`,
            method: 'get'
        })
    },

    save(user) {
        return request({
            url: `${api_name}/save`,
            method: 'post',
            data: user
        })
    },

    updateById(user) {
        return request({
            url: `${api_name}/update`,
            method: 'put',
            data: user
        })
    },
    getAssign(userId) {
        return request({
            url: `${api_name}/toAssign/${userId}`,
            method: 'get'
        })
    },
    saveAssign(userId, roleId) {
        return request({
            url: `${api_name}/doAssign`,
            method: 'post',
            params: { userId, roleId }
        })
    },
    removeById(id) {
        return request({
            url: `${api_name}/remove/${id}`,
            method: 'delete'
        })
    },
    removeRows(idList) {
        return request({
            url: `${api_name}/batchRemove`,
            method: 'delete',
            data: idList
        })
    },
    getImage(imgUrl) {
        return request({
            url: `${api_name}/uploadImg`,
            method: 'get',
            // params: imgUrl
        })
    },

    getLogininforList(data) {
        return request({
            url: `/sys/logininfor/list`,
            method: 'get',
            params: data
        })
    },
    selectCompanyId() {
        return request({
        url: `${api_name}/selectCompanyId`,
        method: 'get',
      })
    },
    getUserinfo() {
        return request({
            url: `${api_name}/getUserinfo`
        })
    },
    selectUsersByCompanyId(companyId) {
        return request({
            url: `${api_name}/selectUsersByCompanyId/${companyId}`,
            method:'get'
        })
    },
    usernameIsExist(username) {
        return request ({
          url: `/admin/acl/user/usernameIsExist/${username}`,
          method: 'get'
        })
    }
}